package gameHandling;

import gameObject.Hero;

import java.util.Enumeration;

import javax.microedition.lcdui.Graphics;

import main.PlayingCanvas;

public class BasicHandling extends ExtendHandling{
	Hero focusHero;
	int t = 0;
	public boolean pointerTaped(int x,int y)
	{
		int i = x/30;
		int j = y/30;
		Enumeration vEnum = PlayingCanvas.getGame().listHero.elements();

		while (vEnum.hasMoreElements()) {
			Hero hero = (Hero) vEnum.nextElement();
			if(hero.getColIndex() == i && hero.getRowIndex() == j)
			{
				PlayingCanvas.getInstance().forcusHero(hero);
				focusHero = hero;
				//break;
				return true;
			}
		}
		focusHero = null;
		PlayingCanvas.getInstance().doneHandling();
		return true;
	}
	
	public void paint(Graphics g) {
		super.paint(g);
		g.setColor(0x00aa00);
		if(focusHero!= null){
			
			/*g.drawArc(focusHero.getX()-focusHero.range,
					focusHero.getY()-focusHero.range+PlayingCanvas.getGame().getY(),
					2*focusHero.range,
					2*focusHero.range,
					0, 360);*/
			int r = focusHero.getViewRange()*t/100;
			g.drawArc(focusHero.getX()-r,
					focusHero.getY()-r+PlayingCanvas.getGame().getY(),
					2*r,
					2*r,
					0, 360);
			r = focusHero.getViewRange()*((t+50)%100)/100;
			g.drawArc(focusHero.getX()-r,
					focusHero.getY()-r+PlayingCanvas.getGame().getY(),
					2*r,
					2*r,
					0, 360);
		}
	}
	public void update() {
		super.update();
		t = (t+5)%100;
		
	}
}
